# -*- coding: utf-8 -*-
# 如果你的程序（包括注释）中包含中文，请加上上面这一行，用于指明编码（utf-8）。
# #号开头的行都是注释。

# 如何编辑本程序：
#     用任何文本编辑器均可编辑。

# 如何运行本程序：
#     在终端中，运行：python p206_if.py

# if:
age = 19
if age >= 18:
    print('You are old enough to vote!')
    print('Have you registered to vote yet?')
# 注意：if后面跟布尔表达式（值只能是True或False）。注意:号和缩进。

print()

# if-else:
age = 17
if age >= 18:
    print('You are old enough to vote!')
    print('Have you registered to vote yet?')
else:
    print('Sorry, you are too young to vote.')
    
print()

    
# if-elif*-else:
age = 12
if age < 4:
    print('Your admission cost is $0.')
elif age < 18:
    print('Your admission cost is $5.')
elif age < 65:
    print('Your admission cost is $10.')
else:
    print('Your admission cost is $5.')
    
print()

# 用if语句检查列表中的特殊元素：

requested_toppings = ['mushrooms', 'green peppers', 'extra cheese']
for t in requested_toppings:
    if t == 'green peppers':
        print('Sorry, we are out of green peppers right now.')
    else:
        print('Adding ' + t + '.')

print()

# 用if语句检查列表是否为空：

requested_toppings = []

if requested_toppings:  # 或者：len(requested_toppings) > 0
    for t in requested_toppings:
        print('Adding ' + t + '.')
    print('Finished making your pizza!')
else:
    print('Are you sure you want a plain pizza?')


    






















